import { listJob, getJob, delJob, addJob, updateJob,} from "@/api/monitor/job";

export const useCommonConfig = ()=>{

  // 基础配置
  const { proxy } = getCurrentInstance()
  const primaryKey = 'jobId'
  const moduleName =  '定时任务'
  const apiFn = {
    listApiFn: listJob,
    delApiFn: delJob,
    apiFnConfig:{
      info: getJob,
      add: addJob,
      edit: updateJob
    }
  }

  // 删除前处理
  const beforeDelFn = (data)=>{
    return Array.isArray(data) ? data.map((item) => item[primaryKey]).join([',']) : data[primaryKey]
  }
  return {
    proxy,
    primaryKey,
    moduleName,
    apiFn,
    beforeDelFn,
  }

}

export const useCommonDict = ()=>{
   const { proxy } = getCurrentInstance()
    const { sys_job_group, sys_job_status}  = proxy.useDict(...[
      "sys_job_group", "sys_job_status"
    ])

    return {
      sys_job_group, sys_job_status
    }

}



